package hd.cls8;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.SimpleTimeZone;

/**
 * @author oldliu
 * @since 1.0
 */
public class Thread1 extends Thread {
    public final static SimpleDateFormat DF = new SimpleDateFormat("yyyy-MM-dd k:mm:ss");

    public Thread1(String name) {
        super(name);//调用父类的构造方法
    }

    @Override
    public void run() {
        for (int i = 1; i <= 20; i++) {
            System.out.println(this.getName() + "输出了" + i + ",时间是" + DF.format(new Date()));
            try {
                sleep((long) (60 * Math.random()));
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
